//
//  MainViewController.swift
//  HKWB
//
//  Created by bovenn on 2017/8/21.
//  Copyright © 2017年 hiking. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
       
        addChildViewController(childVc: HomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(childVc: MessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(childVc: DiscoverViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(childVc: ProfileViewController(), title: "我", imageName: "tabbar_profile")
        
    }

    //swift支持方法的重载
    //private在当前文件中可以访问，但是其他文件不能访问
    private func addChildViewController(childVc: UIViewController,title : String,imageName : String) {
        //2.设置自控制器属性
        childVc.title = title
        childVc.tabBarItem.image=UIImage(named: imageName)
        childVc.tabBarItem.selectedImage = UIImage(named: imageName+"_highlighted")
        //3.包装导航栏控制器
        let childNav = UINavigationController(rootViewController: childVc)
        
        addChildViewController(childNav)
    }
}
